﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
//using Common;
using SilverlightProject.Dialogs;

namespace SilverlightProject.Pages
{
    public partial class UserInfoPage : Page
    {
        private UserInfoDialog _query = null;

        public UserInfoPage()
        {
            InitializeComponent();
        }

        // 当用户导航到此页面时执行。
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            this._query = new UserInfoDialog() { Containers = this.LayoutRoot };
            this._query.Update(this.LayoutRoot);
            this.LayoutRoot.Children.Add(this._query);
            this._query.LoadData += new EventHandler(InitData);
        }

        private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (this._query == null)
                this._query = new UserInfoDialog() { Containers = this };
            this._query.Update(this.LayoutRoot);
        }

        public void InitData(object data,EventArgs e)
        {
            SilverlightServiceReference.SilverlightServiceClient client = new SilverlightProject.SilverlightServiceReference.SilverlightServiceClient();
            client.GetUserListAsync(data.ToString());
            client.GetUserListCompleted += new EventHandler<SilverlightProject.SilverlightServiceReference.GetUserListCompletedEventArgs>(client_GetUserListCompleted);
        }

        void client_GetUserListCompleted(object sender, SilverlightProject.SilverlightServiceReference.GetUserListCompletedEventArgs e)
        {
            this.myGrd.ItemsSource = e.Result;
        }
    }
}
